package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.area.BatchDeleteSaleStrategyRequest;
import com.mes.cloud.api.dto.request.area.BindSaleStrategyRequest;
import com.mes.cloud.api.dto.request.area.OrgSaleStrategyPageListRequest;
import com.mes.cloud.api.dto.request.area.SaleStrategyPageListRequest;
import com.mes.cloud.api.dto.request.product.ProductSaleStrategyPageListRequest;
import com.mes.cloud.api.dto.request.product.SaleStrategyCustomerProductListRequest;
import com.mes.cloud.api.dto.response.area.OrgSaleStrategyDto;
import com.mes.cloud.api.dto.response.area.SaleStrategyDto;
import com.mes.cloud.api.dto.response.product.ProductSaleStrategyDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.BaseAreaSaleStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author dongyi
 * @description
 * @date 2019-08-22 13:42
 **/
@Api(tags = "区域产品分销策略", value = "区域产品分销策略接口")
@RestController
@RequestMapping(value = "/baseAreaSaleStrategy")
public class BaseAreaSaleStrategyController  {

    private BaseAreaSaleStrategyService baseAreaSaleStrategyService;

    @Autowired
    public BaseAreaSaleStrategyController(BaseAreaSaleStrategyService baseAreaSaleStrategyService) {
        this.baseAreaSaleStrategyService = baseAreaSaleStrategyService;
    }

    /**
     * 功能: 区域产品分销策略分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager   <   BaseAreaSaleStrategyDto>>
     */
    @ApiOperation(value = "区域产品分销策略分页查询", notes = "区域产品分销策略分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<SaleStrategyDto>> pageList(@Valid @RequestBody SaleStrategyPageListRequest pageRequest) {
        return baseAreaSaleStrategyService.pageList(pageRequest);
    }

    /**
     * 功能: 根据组织查找产品分销策略
     *
     * @param pageRequest
     * @return JsonResult<CommPager<OrgSaleStrategyDto>>
     */
    @ApiOperation(value = "根据组织查找产品分销策略", notes = "根据组织查找产品分销策略分页查询")
    @PostMapping(value = "/orgPageList")
    public JsonResult<CommPager<OrgSaleStrategyDto>> orgPageList(@Valid @RequestBody OrgSaleStrategyPageListRequest pageRequest) {
        return baseAreaSaleStrategyService.orgPageList(pageRequest);
    }

    /**
     * 功能: 区域产品分销策略新增
     *
     * @param bindSaleStrategyRequest
     * @return JsonResult
     */
    @ApiOperation(value = "区域产品分销策略新增", notes = "区域产品分销策略新增")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody BindSaleStrategyRequest bindSaleStrategyRequest) {
        return baseAreaSaleStrategyService.bindSaleStrategy(bindSaleStrategyRequest);
    }

    /**
     * 功能: 区域产品分销策略批量删除
     *
     * @param batchDeleteSaleStrategyRequest
     * @return JsonResult
     */
    @ApiOperation(value = "区域产品分销策略批量删除", notes = "区域产品分销策略批量删除")
    @PostMapping(value = "/batchDelete")
    public JsonResult batchDelete(@Valid @RequestBody BatchDeleteSaleStrategyRequest batchDeleteSaleStrategyRequest) {
        return baseAreaSaleStrategyService.batchDelete(batchDeleteSaleStrategyRequest);
    }

    /**
     * 功能: 产品分销策略分页查列表
     *
     * @param pageRequest
     * @return JsonResult<CommPager   <   BaseAreaSaleStrategyDto>>
     */
    @ApiOperation(value = "产品分销策略分页查列表", notes = "产品分销策略分页查列表")
    @PostMapping(value = "/productSaleStrategyPageList")
    public JsonResult<CommPager<ProductSaleStrategyDto>> productSaleStrategyPageList(@Valid @RequestBody ProductSaleStrategyPageListRequest pageRequest) {
        return baseAreaSaleStrategyService.productSaleStrategyPageList(pageRequest);
    }

    /**
     * @Author ysd
     * @Description  合作关系（cash）_ 导入分销策略_可售、必售产品
     * @Date 17:13 2019/9/23
     **/
    @ApiOperation(value = " 合作关系（cash）_ 导入分销策略_可售、必售产品", notes = " 合作关系（cash）_ 导入分销策略_可售、必售产品")
    @PostMapping(value = "/selectCustomerProductByCostomer")
    public JsonResult<List<ProductSaleStrategyDto>> selectCustomerProductByCostomer(@Valid @RequestBody SaleStrategyCustomerProductListRequest pageRequest) {
        return baseAreaSaleStrategyService.selectCustomerProductByCostomer(pageRequest);
    }
}
